package com.vincent.kdp.ui.vip.presenter;

import android.content.Intent;

import com.loopj.android.http.RequestParams;
import com.vincent.baseapp.base.BasePresenter;
import com.vincent.kdp.PostUrl;
import com.vincent.kdp.http.HttpUtil;
import com.vincent.kdp.http.RequestCallBack;
import com.vincent.kdp.ui.bean.response.VipInfoOutput;
import com.vincent.kdp.ui.vip.contract.VipDetailContract;
import com.vincent.kdp.ui.vip.repository.VipDetailRepository;
import com.vincent.kdp.util.BaseParam;

public class VipDetailPresenter extends BasePresenter<VipDetailContract.View> implements VipDetailContract.Presenter {
    private VipDetailRepository mRepository;

    public VipDetailPresenter() {
        mRepository = new VipDetailRepository();
    }

    @Override
    public void initView(Intent intent) {
        reqVipDetail(BaseParam.getDeviceId());
    }

    private void reqVipDetail(String vipAccount) {
        if (vipAccount == null || vipAccount.trim().equals("")) {
            mView.showToast("请输入会员账号！");
            return;
        }
        mView.showLoadDialog();

        mRepository.reqVipInfo(vipAccount, new RequestCallBack<VipInfoOutput>() {
            @Override
            public void onSuccess(VipInfoOutput vipInfoOutput) {
                if (mView != null) {
                    mView.dismissLoadDialog();
                }
            }

            @Override
            public void onFalse(String msg) {
                if (mView != null) {
                    mView.dismissLoadDialog();
                    mView.showToast(msg);
                }
            }
        });
    }
}
